package com.cac.demo.util;

import com.cac.demo.entity.tsUSer.RestResult;
import com.cac.demo.entity.tsUSer.ResultCode;
import org.springframework.stereotype.Component;

@Component
public class
ResultGenerator {
    private static final String SUCCESS ="success";
    //成功
    public RestResult getSuccessResult(){
        RestResult restResult = new RestResult();
        restResult.setCode(ResultCode.SUCCESS);
        restResult.setMessage(SUCCESS);
        return restResult;

    }
    public RestResult getSuccessResult(Object data){
        RestResult restResult = new RestResult();
        restResult.setCode(ResultCode.SUCCESS);
        restResult.setMessage(SUCCESS);
        restResult.setData(data);
        return restResult;

    }
    public RestResult getSuccessResult(String message,Object data){
        RestResult restResult = new RestResult();
        restResult.setCode(ResultCode.SUCCESS);
        restResult.setMessage(message);
        restResult.setData(data);
        return restResult;
    }
    public RestResult getFailResult(String message){
        RestResult restResult = new RestResult();
        restResult.setCode(ResultCode.FAIL);
        restResult.setMessage(message);
        return restResult;
    }
    public RestResult getFailResult(String message,Object data){
        RestResult restResult = new RestResult();
        restResult.setCode(ResultCode.FAIL);
        restResult.setMessage(message);
        restResult.setData(data);
        return restResult;
    }
}
